NAME=proxy
BINDIR=bin
# 获取源码最近一次 git commit log，包含 commit sha 值，以及 commit message
GitCommitLog=$(shell git log --pretty=oneline -n 1)
BuildTime=$(shell date +'%Y-%m-%d %H:%M:%S')
GOBUILD=GO111MODULE=on \
		GOPROXY="https://goproxy.cn,direct" \
		GOEXPERIMENT=jsonv2 \
		GOEXPERIMENT=loopvar \
		go build -trimpath -ldflags \
		'-X "go2.GitCommitLog=$(GitCommitLog)" \
    	-X "go2.GitStatus=$(GitStatus)" \
    	-X "go2.BuildTime=$(BuildTime)" \
		-w -s -buildid='

all: clean windows-amd64 strip

PLATFORM_LIST = \
	linux-amd64

clean:
	rm -rf $(BINDIR)

linux-amd64:
	GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@

windows-amd64:
	GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe

macos-amd64:
	GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@

strip:
	upx --best $(BINDIR)/*
